﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bussines;

namespace Bussines
{

    #region clTermekek...
    public class clTermekek
    {
        public int fTRM_ID;
        public string fTRM_NEV;

        public clTermekek(int iTRM_ID, string iTRM_NEV)
        {
            fTRM_ID = iTRM_ID;
            fTRM_NEV = iTRM_NEV;
        }
    }

    public class clTermekekLista : List<clTermekek>
    {
        private SqlConnection sc;
        TBLObj pBLObj = new TBLObj();

        public clTermekekLista(TBLObj iBLObj)
        {
            pBLObj = iBLObj;
            sc = iBLObj.sqlConnection;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = sc;

            cmd.CommandType = CommandType.Text;

            cmd.CommandText = "SELECT TRM_ID,TRM_NEV FROM TERMEKEK " +
                "WHERE TRM_KIZART = 'N' ";

            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                clTermekek t = new clTermekek((int)rdr["TRM_ID"], rdr["TRM_NEV"].ToString());
                this.Add(t);
            }
            rdr.Close();
        }
    }
    #endregion

    #region clKonstrukcio...
    public class clKonstrukcio
    {
        public int fKNS_ID;
        public int fKNS_TRM_ID;
        public string fKNS_NEV;
        public string fKNS_TIPUS;

        public clKonstrukcio(int iKNS_ID , int iKNS_TRM_ID, string iKNS_NEV, string iKNS_TIPUS)
        {
            fKNS_ID = iKNS_ID;
            fKNS_TRM_ID = iKNS_TRM_ID;
            fKNS_NEV = iKNS_NEV;
            fKNS_TIPUS = iKNS_TIPUS;
        }
    }

    public class clKonstrukcioLista : List<clKonstrukcio>
    {
        private SqlConnection sc;

        public clKonstrukcioLista(TBLObj iBLObj, int iKNS_TRM_ID)
        {
            TBLObj pBLObj = iBLObj;
            sc = iBLObj.sqlConnection;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = sc;

            cmd.CommandType = CommandType.Text;

            cmd.CommandText = "SELECT KNS_ID,KNS_NEV,KNS_TIPUS FROM KONSTRUKCIOK " +
                "WHERE KNS_KIZART = 'N' " +
                "AND KNS_TRM_ID  = @KNS_TRM_ID  ";

            cmd.Parameters.Add(new SqlParameter("KNS_TRM_ID", SqlDbType.Int));

            cmd.Parameters["KNS_TRM_ID"].Value = iKNS_TRM_ID; 

            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                clKonstrukcio t = new clKonstrukcio((int)rdr["KNS_ID"], iKNS_TRM_ID, rdr["KNS_NEV"].ToString(), rdr["KNS_TIPUS"].ToString());
                this.Add(t);
            }
            rdr.Close();
        }
    }
    #endregion
/*
    #region clAlgoritmusok...
    public class clAlgoritmus
    {
        public int fALG_ID;
        public int fALG_KNS_ID;
        public string fALG_NEV;
        public string fALG_EDIT;
        public string fALG_COMBO;
        public string[] Edits;

        public clAlgoritmus(int iALG_ID, int iALG_KNS_ID, string iALG_NEV, string iALG_EDIT, string iALG_COMBO)
        {
            fALG_ID = iALG_ID;
            fALG_KNS_ID = iALG_KNS_ID;
            fALG_NEV = iALG_NEV;
            fALG_EDIT = iALG_EDIT;
            fALG_COMBO = iALG_COMBO;

            Edits = iALG_EDIT.Split(';');
        }
    }

    public class clAlgoritmusLista : List<clAlgoritmus>
    {
        private SqlConnection sc;

        public clAlgoritmusLista(TBLObj iBLObj, int iALG_KNS_ID)
        {
            TBLObj pBLObj = iBLObj;
            sc = iBLObj.sqlConnection;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = sc;

            cmd.CommandType = CommandType.Text;

            cmd.CommandText = "SELECT ALG_ID, ALG_KNS_ID, ALG_NEV, ALG_EDIT, ALG_COMBO " +
                "FROM ALGORITMUSOK " +
                "WHERE ALG_KIZART = 'N' " +
                "AND ALG_KNS_ID  = @ALG_KNS_ID  ";

            cmd.Parameters.Add(new SqlParameter("ALG_KNS_ID", SqlDbType.Int));

            cmd.Parameters["ALG_KNS_ID"].Value = iALG_KNS_ID;  

            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                clAlgoritmus t = new clAlgoritmus((int)rdr["ALG_ID"], (int)rdr["ALG_KNS_ID"], rdr["ALG_NEV"].ToString(), rdr["ALG_EDIT"].ToString(), rdr["ALG_COMBO"].ToString());
                this.Add(t);
            }
            rdr.Close();
        }
    }
    #endregion
 */
}
